<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试结果 - ${score.courseName}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        .score-display {
            font-size: 4rem;
            font-weight: bold;
            color: #28a745;
        }
        .result-card {
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/dashboard"><i class="fa fa-graduation-cap me-2"></i>学生考试管理系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/dashboard"><i class="fa fa-tachometer me-1"></i>仪表盘</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/exams"><i class="fa fa-list-alt me-1"></i>考试列表</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="#"><i class="fa fa-check-circle me-1"></i>考试结果</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/logout"><i class="fa fa-sign-out me-1"></i>退出登录</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card result-card">
                    <div class="card-header bg-primary text-white text-center">
                        <h3 class="mb-0"><i class="fa fa-certificate me-2"></i>考试成绩详情</h3>
                    </div>
                    <div class="card-body">
                        <!-- 错误提示 -->
                        <c:if test="${not empty error}">
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                <i class="fa fa-exclamation-circle me-2"></i>${error}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                            <div class="text-center mt-4">
                                <a href="/exams" class="btn btn-primary"><i class="fa fa-arrow-left me-2"></i>返回考试列表</a>
                            </div>
                        </c:if>

                        <!-- 成绩信息 -->
                        <c:if test="${empty error}">
                            <div class="text-center mb-4">
                                <h2>${score.courseName} 考试成绩</h2>
                                <p class="text-muted">考试日期: ${score.examDate}</p>
                            </div>

                            <div class="row mb-5">
                                <div class="col-12 text-center">
                                    <div class="score-display">${score.score}</div>
                                    <p class="text-muted">满分: ${score.totalScore}分</p>
                                    <c:choose>
                                        <c:when test="${score.score >= 60}">
                                            <span class="badge bg-success fs-5"><i class="fa fa-check-circle me-1"></i>考试通过</span>
                                        </c:when>
                                        <c:otherwise>
                                            <span class="badge bg-danger fs-5"><i class="fa fa-times-circle me-1"></i>考试未通过</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>

                            <div class="table-responsive">
                                <table class="table table-striped table-hover">
                                    <tbody>
                                        <tr>
                                            <th scope="row" style="width: 30%;">学生姓名</th>
                                            <td>${score.studentName}</td>
                                        </tr>
                                        <tr>
                                            <th scope="row">学号</th>
                                            <td>${score.studentId}</td>
                                        </tr>
                                        <tr>
                                            <th scope="row">考试ID</th>
                                            <td>${score.examId}</td>
                                        </tr>
                                        <tr>
                                            <th scope="row">考试状态</th>
                                            <td>${score.status}</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                            <div class="d-flex justify-content-center mt-5">
                                <a href="/dashboard" class="btn btn-outline-primary me-3">
                                    <i class="fa fa-tachometer me-1"></i>返回仪表盘
                                </a>
                                <a href="/exams" class="btn btn-primary">
                                    <i class="fa fa-list-alt me-1"></i>查看其他考试
                                </a>
                            </div>
                        </c:if>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>